//
//  MKUISegmentFlowLayoutConstraint.m
//  MKUI
//
//  Created by sushangjin on 16/2/27.
//  Copyright © 2016年 sushangjin. All rights reserved.
//

#import "MKUISegmentFlowLayoutConstraint.h"
#import "MKUIFlowLayoutConstraint.h"
@interface MKUISegmentFlowLayoutConstraint (){
	BOOL __needConfigSubFlowLayouts;
}
@property(nonatomic,strong) MKUIFlowLayoutConstraint *beforeItemsFlowlayout;
@property(nonatomic,strong) MKUIFlowLayoutConstraint *afterItemsFlowlayout;
@end

@implementation MKUISegmentFlowLayoutConstraint

- (id)copyWithZone:(NSZone *)zone{
    MKUISegmentFlowLayoutConstraint *obj = [super copyWithZone:zone];
    obj.layoutDirection = self.layoutDirection;
    obj.layoutVerticalAlignment = self.layoutVerticalAlignment;
    obj.layoutHorizontalAlignment = self.layoutHorizontalAlignment;
    obj.contentInsets = self.contentInsets;
    obj.interitemSpacing = self.interitemSpacing;
    obj.boundaryItemIndex = self.boundaryItemIndex;
    obj.isLayoutPriorityFirstItems = self.isLayoutPriorityFirstItems;
    obj.layoutPriorityItemsMaxBoundsPercent = self.layoutPriorityItemsMaxBoundsPercent;
    obj.fixSizeToFitsBounds = self.fixSizeToFitsBounds;
    return obj;
}
- (id)init{
	if (self=[super init]) {
		self.beforeItemsFlowlayout = [[MKUIFlowLayoutConstraint alloc] init];
		self.afterItemsFlowlayout = [[MKUIFlowLayoutConstraint alloc] init];
		_layoutDirection = MKUILayoutConstraintDirectionHorizontal;
		_layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentCenter;
		_isLayoutPriorityFirstItems = NO;
		_layoutPriorityItemsMaxBoundsPercent= 0.75;
		__needConfigSubFlowLayouts = YES;
	}
	return self;
}
- (void)setBoundaryItemIndexWithItem:(id<MKUILayoutConstraintItemProtocol>)item{
	NSInteger index = [self.items indexOfObject:item];
	if(index!=NSNotFound){
		self.boundaryItemIndex = index;
	}else{
		//出错了
	}
}
- (void)setBoundaryItemIndex:(NSInteger)boundaryItemIndex{
	_boundaryItemIndex = boundaryItemIndex;
	__needConfigSubFlowLayouts = YES;
}
- (void)setLayoutDirection:(MKUILayoutConstraintDirection)layoutDirection{
	_layoutDirection = layoutDirection;
	__needConfigSubFlowLayouts = YES;
}
- (void)setLayoutHorizontalAlignment:(MKUILayoutConstraintHorizontalAlignment)layoutHorizontalAlignment{
	_layoutHorizontalAlignment = layoutHorizontalAlignment;
	__needConfigSubFlowLayouts = YES;
}
- (void)setLayoutVerticalAlignment:(MKUILayoutConstraintVerticalAlignment)layoutVerticalAlignment{
	_layoutVerticalAlignment = layoutVerticalAlignment;
	__needConfigSubFlowLayouts = YES;
}
- (void)setItems:(NSArray *)items{
	[super setItems:items];
	__needConfigSubFlowLayouts = YES;
}
- (void)setInteritemSpacing:(CGFloat)interitemSpacing{
	_interitemSpacing = interitemSpacing;
	__needConfigSubFlowLayouts = YES;
}
- (void)setContentInsets:(UIEdgeInsets)contentInsets{
	_contentInsets = contentInsets;
	__needConfigSubFlowLayouts = YES;
}
- (void)__configSubFlowLayouts{
	__needConfigSubFlowLayouts = NO;
	self.beforeItemsFlowlayout.items = [self.items subarrayWithRange:NSMakeRange(0, self.boundaryItemIndex+1)];
	self.afterItemsFlowlayout.items = [self.items subarrayWithRange:NSMakeRange(self.boundaryItemIndex+1, self.items.count-self.boundaryItemIndex-1)];
	//
	self.beforeItemsFlowlayout.interitemSpacing = self.interitemSpacing;
	self.afterItemsFlowlayout.interitemSpacing = self.interitemSpacing;
	//
	self.beforeItemsFlowlayout.layoutDirection = self.layoutDirection;
	self.afterItemsFlowlayout.layoutDirection = self.layoutDirection;
	//
	if(self.layoutDirection==MKUILayoutConstraintDirectionHorizontal){//水平方向布局,A B C
		self.beforeItemsFlowlayout.layoutVerticalAlignment = self.layoutVerticalAlignment;
		self.afterItemsFlowlayout.layoutVerticalAlignment = self.layoutVerticalAlignment;
		self.beforeItemsFlowlayout.layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentLeft;
		self.afterItemsFlowlayout.layoutHorizontalAlignment = MKUILayoutConstraintHorizontalAlignmentRight;
	}else{//垂直方向布局
		/**
		 A
		 B
		 C
		 */
		self.beforeItemsFlowlayout.layoutHorizontalAlignment = self.layoutHorizontalAlignment;
		self.afterItemsFlowlayout.layoutHorizontalAlignment = self.layoutHorizontalAlignment;
		self.beforeItemsFlowlayout.layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentTop;
		self.afterItemsFlowlayout.layoutVerticalAlignment = MKUILayoutConstraintVerticalAlignmentBottom;
	}
}
- (CGSize)sizeThatFits:(CGSize)size resizeItems:(BOOL)resizeItems{
//	if(__needConfigSubFlowLayouts){
		[self __configSubFlowLayouts];
//	}
	CGSize sizeFits = CGSizeZero;
	UIEdgeInsets insets = self.contentInsets;
	CGRect bounds = CGRectZero;
	bounds.size = size;
	bounds = UIEdgeInsetsInsetRect(bounds, insets);
	CGFloat space = self.interitemSpacing;
	if(self.beforeItemsFlowlayout.layoutedItems.count==0||self.afterItemsFlowlayout.layoutedItems.count==0){
		space = 0;
	}
	CGRect f1 = bounds;
	CGRect f2 = bounds;
	CGSize f1_size_fit  = [self.beforeItemsFlowlayout sizeThatFits:f1.size resizeItems:resizeItems];
	CGSize f2_size_fit = [self.afterItemsFlowlayout sizeThatFits:f2.size resizeItems:resizeItems];
	MKCGAxis axis = self.layoutDirection==MKUILayoutConstraintDirectionHorizontal?MKCGAxisX:MKCGAxisY;
	MKCGAxis axisR = MKCGAxisReverse(axis);
	if(self.isLayoutPriorityFirstItems){
		if(CGSizeEqualToSize(f2_size_fit, CGSizeZero)){//后半部分没有占用空间,空间全部分配给前半部分
			if(!CGSizeEqualToSize(f1_size_fit, CGSizeZero)){
				sizeFits.width = insets.left+insets.right+f1_size_fit.width;
				sizeFits.height = insets.top+insets.bottom+f1_size_fit.height;
			}
		}else{
			MKCGRectSetLength(&f1, axis, self.layoutPriorityItemsMaxBoundsPercent*(MKCGRectGetLength(bounds, axis)-space));
			CGSize f1_size = f1_size_fit.width<=f1.size.width&&f1_size_fit.height<=f1.size.height?f1_size_fit:[self.beforeItemsFlowlayout sizeThatFits:f1.size resizeItems:resizeItems];
			f1.size.width = MIN(f1_size.width,f1.size.width);
			f1.size.height = MIN(f1_size.height,f1.size.height);
			//
            
            MKCGRectSetLength(&f2, axis, MKCGRectGetLength(bounds, axis)-MKCGRectGetLength(f1, axis));
            if(MKCGRectGetLength(f1, axis)>0){
                MKCGRectAddLength(&f2, axis, -space);
            }
			CGSize f2_size = f2_size_fit.width<=f2.size.width&&f2_size_fit.height<=f2.size.height?f2_size_fit:[self.afterItemsFlowlayout sizeThatFits:f2.size resizeItems:resizeItems];
			f2.size.width = MIN(f2_size.width,f2.size.width);
			f2.size.height = MIN(f2_size.height,f2.size.height);
			CGFloat maxLengthAxisR = MAX(MKCGRectGetLength(f1, axisR),MKCGRectGetLength(f2, axisR));
			if(maxLengthAxisR){
				MKCGSizeSetLength(&sizeFits, axisR, maxLengthAxisR+MKUIEdgeInsetsGetEdge(insets, axisR, MKUIEdgeInsetsMin)+MKUIEdgeInsetsGetEdge(insets, axisR, MKUIEdgeInsetsMax));
			}
			if(MKCGRectGetLength(f1, axis)+MKCGRectGetLength(f2, axis)>0){
				MKCGSizeSetLength(&sizeFits, axis, MKUIEdgeInsetsGetEdge(insets, axis, MKUIEdgeInsetsMin)+MKUIEdgeInsetsGetEdge(insets, axis, MKUIEdgeInsetsMax)+MKCGRectGetLength(f1, axis)+MKCGRectGetLength(f2, axis));
                if(MKCGRectGetLength(f1, axis)>0 && MKCGRectGetLength(f2, axis)>0){
                    MKCGSizeAddLength(&sizeFits, axis, space);
                }
			}
		}
	}else{
		if(CGSizeEqualToSize(f1_size_fit, CGSizeZero)){//前半部分没有占用空间,空间全部分配给后半部分
			if(!CGSizeEqualToSize(f2_size_fit, CGSizeZero)){
				sizeFits.width = insets.left+insets.right+f2_size_fit.width;
				sizeFits.height = insets.top+insets.bottom+f2_size_fit.height;
			}
		}else{
			MKCGRectSetLength(&f2, axis, self.layoutPriorityItemsMaxBoundsPercent*(MKCGRectGetLength(bounds, axis)-space));
			CGSize f2_size = f2_size_fit.width<=f2.size.width&&f2_size_fit.height<=f2.size.height?f2_size_fit:[self.afterItemsFlowlayout sizeThatFits:f2.size resizeItems:resizeItems];
			f2.size.width = MIN(f2_size.width,f2.size.width);
			f2.size.height = MIN(f2_size.height,f2.size.height);
			//
			MKCGRectSetLength(&f1, axis, MKCGRectGetLength(bounds, axis)-MKCGRectGetLength(f2, axis));
            if(MKCGRectGetLength(f2, axis)>0){
                MKCGRectAddLength(&f1, axis, -space);
            }
			CGSize f1_size = f1_size_fit.width<=f1.size.width&&f1_size_fit.height<=f1.size.height?f1_size_fit:[self.beforeItemsFlowlayout sizeThatFits:f1.size resizeItems:resizeItems];
			f1.size.width = MIN(f1_size.width,f1.size.width);
			f1.size.height = MIN(f1_size.height,f1.size.height);
			
			CGFloat maxLengthAxisR = MAX(MKCGRectGetLength(f1, axisR),MKCGRectGetLength(f2, axisR));
			if(maxLengthAxisR){
				MKCGSizeSetLength(&sizeFits, axisR, maxLengthAxisR+MKUIEdgeInsetsGetEdge(insets, axisR, MKUIEdgeInsetsMin)+MKUIEdgeInsetsGetEdge(insets, axisR, MKUIEdgeInsetsMax));
			}
			if(MKCGRectGetLength(f1, axis)+MKCGRectGetLength(f2, axis)>0){
				MKCGSizeSetLength(&sizeFits, axis, MKUIEdgeInsetsGetEdge(insets, axis, MKUIEdgeInsetsMin)+MKUIEdgeInsetsGetEdge(insets, axis, MKUIEdgeInsetsMax)+MKCGRectGetLength(f1, axis)+MKCGRectGetLength(f2, axis));
                if(MKCGRectGetLength(f1, axis)>0 && MKCGRectGetLength(f2, axis)>0){
                    MKCGSizeAddLength(&sizeFits, axis, space);
                }
			}
		}
	}
	
	if(self.fixSizeToFitsBounds){
		MKCGSizeSetLength(&sizeFits, axis, MKCGSizeGetLength(size, axis));
	}
	return sizeFits;
}
- (void)layoutItems{
//	if(__needConfigSubFlowLayouts){
		[self __configSubFlowLayouts];
//	}
	[self layoutItemsWithResizeItems:NO];
}
- (void)layoutItemsWithResizeItems:(BOOL)resizeItems{
//	if(__needConfigSubFlowLayouts){
		[self __configSubFlowLayouts];
//	}
	UIEdgeInsets insets = self.contentInsets;
	CGRect bounds = UIEdgeInsetsInsetRect(self.bounds, insets);
	CGFloat space = self.interitemSpacing;
	if(self.beforeItemsFlowlayout.layoutedItems.count==0||self.afterItemsFlowlayout.layoutedItems.count==0){
		space = 0;
	}
	CGRect f1 = bounds;
	CGRect f2 = bounds;
	MKCGAxis axis = self.layoutDirection==MKUILayoutConstraintDirectionHorizontal?MKCGAxisX:MKCGAxisY;
//	MKCGAxis axisR = MKCGAxisReverse(axis);
	if(self.isLayoutPriorityFirstItems){
		BOOL isAfterItemsEmpty = [self.afterItemsFlowlayout isEmptyBounds:f2 withResizeItems:resizeItems];
		if(isAfterItemsEmpty){
			self.beforeItemsFlowlayout.bounds = f1;
			[self.beforeItemsFlowlayout layoutItemsWithResizeItems:resizeItems];
		}else{
			MKCGRectSetLength(&f1, axis, self.layoutPriorityItemsMaxBoundsPercent*(MKCGRectGetLength(bounds, axis)-space));
			CGSize f1_size = [self.beforeItemsFlowlayout sizeThatFits:f1.size resizeItems:resizeItems];
			MKCGRectSetLength(&f1, axis, MIN(MKCGSizeGetLength(f1_size, axis), MKCGRectGetLength(f1, axis)));
			self.beforeItemsFlowlayout.bounds = f1;
			[self.beforeItemsFlowlayout layoutItemsWithResizeItems:resizeItems];
			//
			MKCGRectSetMin(&f2, axis, MKCGRectGetMax(f1, axis));
            if(MKCGRectGetLength(f1, axis)>0){
                MKCGRectAddMin(&f2, axis, space);
            }
			MKCGRectSetLength(&f2, axis, MKCGRectGetMax(bounds, axis)-MKCGRectGetMin(f2, axis));
			self.afterItemsFlowlayout.bounds = f2;
			[self.afterItemsFlowlayout layoutItemsWithResizeItems:resizeItems];
		}
	}else{
		BOOL isBeforeItemsEmpty = [self.beforeItemsFlowlayout isEmptyBounds:f1 withResizeItems:resizeItems];
		if(isBeforeItemsEmpty){
			self.afterItemsFlowlayout.bounds = f2;
			[self.afterItemsFlowlayout layoutItemsWithResizeItems:resizeItems];
		}else{
			MKCGRectSetLength(&f2, axis, self.layoutPriorityItemsMaxBoundsPercent*(MKCGRectGetLength(bounds, axis)-space));
			CGSize f2_size = [self.afterItemsFlowlayout sizeThatFits:f2.size resizeItems:resizeItems];
			MKCGRectSetLength(&f2, axis, MIN(MKCGSizeGetLength(f2_size, axis),MKCGRectGetLength(f2, axis)));
			MKCGRectSetMin(&f2, axis, MKCGRectGetMax(bounds, axis)-MKCGRectGetLength(f2, axis));
			self.afterItemsFlowlayout.bounds = f2;
			[self.afterItemsFlowlayout layoutItemsWithResizeItems:resizeItems];
			//
            MKCGRectSetLength(&f1, axis, MKCGRectGetMin(f2, axis)-MKCGRectGetMin(f1, axis));
            if(MKCGRectGetLength(f2, axis)>0){
                MKCGRectAddLength(&f1, axis, -space);
            }
			self.beforeItemsFlowlayout.bounds = f1;
			[self.beforeItemsFlowlayout layoutItemsWithResizeItems:resizeItems];
		}
	}
}
@end
MKDEF_EnumTypeCategories(MKUISegmentFlowLayoutConstraintParam,
(@{
   @(MKUISegmentFlowLayoutConstraint_H_C):@"H_C",
   @(MKUISegmentFlowLayoutConstraint_H_T):@"H_T",
   @(MKUISegmentFlowLayoutConstraint_H_B):@"H_B",
   @(MKUISegmentFlowLayoutConstraint_V_C):@"V_C",
   @(MKUISegmentFlowLayoutConstraint_V_L):@"V_L",
   @(MKUISegmentFlowLayoutConstraint_V_R):@"V_R",
   }))
@implementation MKUISegmentFlowLayoutConstraint (InitMethod)
//////////////////////////////////////////////////////////////////////////////
+ (NSDictionary<NSNumber *,NSArray<NSNumber *> *> *)ConstraintParamMapOfHorizontal{
	static NSDictionary<NSNumber *,NSArray<NSNumber *> *> * __share__;
	static dispatch_once_t onceToken;
	dispatch_once(&onceToken, ^{
		NSMutableDictionary<NSNumber *,NSArray<NSNumber *> *> *map = [[NSMutableDictionary alloc] init];
		map[@(MKUISegmentFlowLayoutConstraint_H_C)] = @[
		  @(MKUILayoutConstraintDirectionHorizontal),
		  @(MKUILayoutConstraintVerticalAlignmentCenter),
		  ];
		map[@(MKUISegmentFlowLayoutConstraint_H_T)] = @[
		  @(MKUILayoutConstraintDirectionHorizontal),
		  @(MKUILayoutConstraintVerticalAlignmentTop),
		  ];
		map[@(MKUISegmentFlowLayoutConstraint_H_B)] = @[
		  @(MKUILayoutConstraintDirectionHorizontal),
		  @(MKUILayoutConstraintVerticalAlignmentBottom),
		  ];
		__share__ = map;
	});
	return __share__;
}
+ (NSDictionary<NSNumber *,NSArray<NSNumber *> *> *)ConstraintParamMapOfVertical{
	static NSDictionary<NSNumber *,NSArray<NSNumber *> *> * __share__;
	static dispatch_once_t onceToken;
	dispatch_once(&onceToken, ^{
		NSMutableDictionary<NSNumber *,NSArray<NSNumber *> *> *map = [[NSMutableDictionary alloc] init];
		map[@(MKUISegmentFlowLayoutConstraint_V_C)] = @[
		  @(MKUILayoutConstraintDirectionVertical),
		  @(MKUILayoutConstraintHorizontalAlignmentCenter),
		  ];
		map[@(MKUISegmentFlowLayoutConstraint_V_L)] = @[
		  @(MKUILayoutConstraintDirectionVertical),
		  @(MKUILayoutConstraintHorizontalAlignmentLeft),
		  ];
		map[@(MKUISegmentFlowLayoutConstraint_V_R)] = @[
		  @(MKUILayoutConstraintDirectionVertical),
		  @(MKUILayoutConstraintHorizontalAlignmentRight),
		  ];
		__share__ = map;
	});
	return __share__;
}
+ (NSDictionary<NSArray<NSNumber *> *,NSNumber *> *)ConstraintParamRevertMapOfHorizontal{
	static NSDictionary<NSArray<NSNumber *> *,NSNumber *> * __share__;
	static dispatch_once_t onceToken;
	dispatch_once(&onceToken, ^{
		NSDictionary<NSNumber *,NSArray<NSNumber *> *> *ConstraintParamMap = [self ConstraintParamMapOfHorizontal];
		NSMutableDictionary<NSArray<NSNumber *> *,NSNumber *> *map = [[NSMutableDictionary alloc] initWithCapacity:ConstraintParamMap.count];
		for (NSNumber *key in ConstraintParamMap) {
			map[ConstraintParamMap[key]] = key;
		}
		__share__ = map;
	});
	return __share__;
}
+ (NSDictionary<NSArray<NSNumber *> *,NSNumber *> *)ConstraintParamRevertMapOfVertical{
	static NSDictionary<NSArray<NSNumber *> *,NSNumber *> * __share__;
	static dispatch_once_t onceToken;
	dispatch_once(&onceToken, ^{
		NSDictionary<NSNumber *,NSArray<NSNumber *> *> *ConstraintParamMap = [self ConstraintParamMapOfVertical];
		NSMutableDictionary<NSArray<NSNumber *> *,NSNumber *> *map = [[NSMutableDictionary alloc] initWithCapacity:ConstraintParamMap.count];
		for (NSNumber *key in ConstraintParamMap) {
			map[ConstraintParamMap[key]] = key;
		}
		__share__ = map;
	});
	return __share__;
}
+ (void)parseConstraintParam:(MKUISegmentFlowLayoutConstraintParam)param layoutDirection:(MKUILayoutConstraintDirection *)layoutDirection layoutVerticalAlignment:(MKUILayoutConstraintVerticalAlignment *)layoutVerticalAlignment layoutHorizontalAlignment:(MKUILayoutConstraintHorizontalAlignment *)layoutHorizontalAlignment{
	NSDictionary<NSNumber *,NSArray<NSNumber *> *> *ConstraintParamMapOfHorizontal = [self.class ConstraintParamMapOfHorizontal];
	NSDictionary<NSNumber *,NSArray<NSNumber *> *> *ConstraintParamMapOfVertical = [self.class ConstraintParamMapOfVertical];
	NSArray<NSNumber *> *enums = ConstraintParamMapOfHorizontal[@(param)];
	if(enums){
		*layoutDirection = [enums[0] integerValue];
		*layoutVerticalAlignment = [enums[1] integerValue];
	}else{
		enums = ConstraintParamMapOfVertical[@(param)];
		*layoutDirection = [enums[0] integerValue];
		*layoutHorizontalAlignment = [enums[1] integerValue];
	}
}
+ (MKUISegmentFlowLayoutConstraintParam)constraintParamWithLayoutDirection:(MKUILayoutConstraintDirection)layoutDirection layoutVerticalAlignment:(MKUILayoutConstraintVerticalAlignment)layoutVerticalAlignment layoutHorizontalAlignment:(MKUILayoutConstraintHorizontalAlignment)layoutHorizontalAlignment{
	MKUISegmentFlowLayoutConstraintParam param;
	if(layoutDirection==MKUILayoutConstraintDirectionHorizontal){
		NSDictionary<NSArray<NSNumber *> *,NSNumber *> *ConstraintParamRevertMapOfHorizontal = [self.class ConstraintParamRevertMapOfHorizontal];
		param = (MKUISegmentFlowLayoutConstraintParam)[ConstraintParamRevertMapOfHorizontal[@[@(layoutDirection),@(layoutVerticalAlignment)]] integerValue];
	}else{
		NSDictionary<NSArray<NSNumber *> *,NSNumber *> *ConstraintParamRevertMapOfVertical = [self.class ConstraintParamRevertMapOfVertical];
		param = (MKUISegmentFlowLayoutConstraintParam)[ConstraintParamRevertMapOfVertical[@[@(layoutDirection),@(layoutHorizontalAlignment)]] integerValue];
	}
	return param;
}
//////////////////////////////////////////////////////////////////////////////
- (id)initWithItems:(NSArray<id<MKUILayoutConstraintItemProtocol>> *)items constraintParam:(MKUISegmentFlowLayoutConstraintParam)param contentInsets:(UIEdgeInsets)contentInsets interitemSpacing:(CGFloat)interitemSpacing{
	if(self=[self init]){
		self.items = items;
		[self configWithConstraintParam:param];
		self.contentInsets = contentInsets;
		self.interitemSpacing = interitemSpacing;
	}
	return self;
}
- (MKUISegmentFlowLayoutConstraintParam)constraintParam{
	MKUISegmentFlowLayoutConstraintParam param = [self.class constraintParamWithLayoutDirection:self.layoutDirection layoutVerticalAlignment:self.layoutVerticalAlignment layoutHorizontalAlignment:self.layoutHorizontalAlignment];
	return param;
}
- (void)setConstraintParam:(MKUISegmentFlowLayoutConstraintParam)constraintParam{
	[self configWithConstraintParam:constraintParam];
}
- (void)configWithConstraintParam:(MKUISegmentFlowLayoutConstraintParam)param{
	MKUILayoutConstraintDirection layoutDirection;
	MKUILayoutConstraintVerticalAlignment layoutVerticalAlignment;
	MKUILayoutConstraintHorizontalAlignment layoutHorizontalAlignment;
	[self.class parseConstraintParam:param layoutDirection:&layoutDirection layoutVerticalAlignment:&layoutVerticalAlignment layoutHorizontalAlignment:&layoutHorizontalAlignment];
	self.layoutDirection = layoutDirection;
	self.layoutVerticalAlignment = layoutVerticalAlignment;
	self.layoutHorizontalAlignment = layoutHorizontalAlignment;
}
@end
